/**
 * Depends:
 * utility.init.js
 */ 
utility.json.render = function(options){
	this.init = function(){
		options = options || {};
		options.snippet = options.snippet || "<option value='$value$'>$name$</option>";
		options.data = options.data || [];
		options.selected = options.selected || 0;
	
	};
	
	this.renderRow = function(row){
		if(typeof row.id == "undefined" ) return '';
		if(row.id==options.selected){
			return options.snippet.replaceAll('$value$', row.id).replaceAll('$name$', row.name).replaceAll('option', 'option selected="selected"')
		}
		return options.snippet.replaceAll('$value$', row.id).replaceAll('$name$', row.name);
	};
	
	this.renderCollection = function(collection){
		var items = ""; 
		for(i in collection){
			items += this.renderRow(collection[i]);
		}
		return items;
	};
	
	
	this.init();
	return this.renderCollection(options.data);
};